import instance from '@/utils/request'
import { IAxiosRes } from '.'

/**获取用户的频道
基本信息
Path： /v1_0/user/channels
Method： GET
 */
export declare type TChannels = {
  id: number
  name: string
}
export const getUserChannels = (): IAxiosRes<{ channels: TChannels[] }> => {
  return instance({
    url: '/user/channels'
  })
}

/**
 * 获取所有频道列表
   基本信息
   Path： /v1_0/channels
   Method： GET
 */
export const getChannels = (): IAxiosRes<{ channels: TChannels[] }> => {
  return instance({
    url: '/channels'
  })
}

/**
* 设置用户的频道（部分覆盖）
  基本信息
  Path： /v1_0/user/channels
  Method： PATCH
*/

export const patchUserChannels = (channels:TChannels[]) => {
  return instance({
    url: '/user/channels',
    method:'patch',
    data:{
      channels:channels
    }
  })
}

/**
 * 删除指定用户频道
   基本信息
   Path： /v1_0/user/channels/:target
   Method： DELETE
 */
   export const deleteUserChannels = (id:number) => {
    return instance({
      url: '/user/channels/'+id,
      method:'delete',
    })
  }